package com.ruoyi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.AdvInoutstock;
import com.ruoyi.domain.AdvUpgrade;
import com.ruoyi.service.AdvUpgradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/upgrade")
public class AdvUpgradeController extends BaseController {


        @Autowired
        private AdvUpgradeService advUpgradeService;

        /**
         * 查询列表
         */
        @PreAuthorize("@ss.hasPermi('system:advUpgrade:list')")
        @GetMapping("/list")
        public TableDataInfo list(AdvUpgrade advUpgrade)
        {
            startPage();
            List<AdvUpgrade> list = advUpgradeService.selectAdvUpgradeList(advUpgrade);
            return getDataTable(list);
        }

        /**
         * 导出列表
         */
        @PreAuthorize("@ss.hasPermi('system:advUpgrade:export')")
        @Log(title = "", businessType = BusinessType.EXPORT)
        @PostMapping("/export")
        public void export(HttpServletResponse response, AdvUpgrade advUpgrade)
        {
            List<AdvUpgrade> list = advUpgradeService.selectAdvUpgradeList(advUpgrade);
            ExcelUtil<AdvUpgrade> util = new ExcelUtil<AdvUpgrade>(AdvUpgrade.class);
            util.exportExcel(response, list, "数据");
        }

        /**
         * 新增
         */
        @RepeatSubmit
        @PreAuthorize("@ss.hasPermi('system:advUpgrade:add')")
        @Log(title = "", businessType = BusinessType.INSERT)
        @PostMapping
        public AjaxResult add(@RequestBody AdvUpgrade advUpgrade)
        {
            return toAjax(advUpgradeService.insertAdvUpgrade(advUpgrade));
        }

        /**
         * 修改
         */
        @PreAuthorize("@ss.hasPermi('system:advUpgrade:edit')")
        @Log(title = "", businessType = BusinessType.UPDATE)
        @PutMapping
        public AjaxResult edit(@RequestBody AdvUpgrade advUpgrade)
        {
            return toAjax(advUpgradeService.updateAdvUpgrade(advUpgrade));
        }

        /**
         * 删除
         */
        @PreAuthorize("@ss.hasPermi('system:advUpgrade:remove')")
        @Log(title = "", businessType = BusinessType.DELETE)
        @DeleteMapping("/{advUpgradeIds}")
        public AjaxResult remove(@PathVariable Long[] advUpgradeIds)
        {
                return toAjax(advUpgradeService.deleteAdvUpgradeByAdvUpgradeId(advUpgradeIds));
        }


}
